// pages/ordersList/ordersList.js
var sliderWidth = 96; // 需要设置slider的宽度，用于计算中间位置
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    proList: [1, 2, 3, 4, 5, 6, 7, 8, 9],
    showTip: false,
    tabs: ["全部", "待付款", "待收货", "已收货", "待评价"],
    activeIndex: 1,
    sliderOffset: 0,
    sliderLeft: 0,
    orderlist:[]
  },
  showTip: function () {
    var that = this
    // wx.showLoading({
    //   title: '加载中',
    // })

    setTimeout(function () {
      var animation = wx.createAnimation({
        duration: 1000,
        timingFunction: 'ease'
      });
      animation.translate(0, -180).step()
      that.setData({
        showTip: true,
      })
      setTimeout(function () {
        that.setData({
          ani: animation.export()
        })
      }, 1)
      wx.hideLoading()
    }, 1000)
  },
  closeTip: function (e) {
    var animation = wx.createAnimation({
      duration: 1000,
      timingFunction: 'ease'
    });
    animation.translate(0, 0).step()
    if (e.target.id) {
      this.setData({
        showTip: false,
        ani: animation.export()
      })
    }

  },

  onLoad: function () {
    var that = this;
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          sliderLeft: (res.windowWidth / that.data.tabs.length - sliderWidth) / 2,
          sliderOffset: res.windowWidth / that.data.tabs.length * that.data.activeIndex
        });
      }
    });
  },
  tabClick: function (e) {
    this.setData({
      sliderOffset: e.currentTarget.offsetLeft,
      activeIndex: e.currentTarget.id
    });
  },

  // 订单编号
   orderlist:function() {
     var that = this
     app.req({
       url:'SalesOrder',
       success:function(res) {
        that.setData({
          orderlist:res.data.Result
        })

       }

     })
   },


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.orderlist()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})